package com.itheima.controller;

import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    /**
     * 查询所有套餐
     * @return
     */
    @PostMapping("/getSetmeal")
    public Result getSetmeal() {
        log.info("查询所有套餐");
        List<Setmeal> list = setmealService.getSetmeal();
        return Result.success(list);
    }

    /**
     * 根据套餐id查询对应套餐详情
     * @param id
     * @return
     */
    @PostMapping("/findById")
    public Result findById(Integer id) {
        log.info("查询套餐详情");
        Setmeal setmeal = setmealService.findById(id);
        return Result.success(setmeal);
    }
}
